﻿using System.Collections.Generic;
using SFML.Graphics;

namespace Discipulus
{
	static class ResourceManager
	{
		private static Dictionary<string, Image> images = new Dictionary<string, Image>();
		private static Dictionary<string, Font> fonts = new Dictionary<string, Font>();

		// Images.

		public static Image LoadImage(string path)
		{
			path = "Resources\\" + path;

			Image image = new Image(path);
			image.Smooth = false;

			images.Add(path, image);

			return image;
		}

		public static void UnloadImage(string path)
		{
			images[path] = null;

			images.Remove(path);
		}

		public static Image GetImage(string path)
		{
			return images.ContainsKey(path) ? images[path] : LoadImage(path);
		}

		// Fonts.

		public static Font LoadFont(string path)
		{
			path = "Resources\\" + path;

			Font font = new Font(path);

			fonts.Add(path, font);

			return font;
		}

		public static void UnloadFont(string path)
		{
			fonts[path] = null;

			fonts.Remove(path);
		}

		public static Font GetFont(string path)
		{
			return fonts.ContainsKey(path) ? fonts[path] : LoadFont(path);
		}
	}
}
